package com.lhoverc.controller.admin;

import com.lhoverc.pojo.PageBean;
import com.lhoverc.pojo.Result;
import com.lhoverc.service.log.LogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

/**
 * @Author: LiCheng
 * @CreateTime: 2025-04-27
 * @Description:
 * @Version: 1.0
 */
@Slf4j
@RestController
@RequestMapping("/admin/log")
public class AdminLogController {

    @Autowired
    private LogService logService;

    /**
     * 分页条件查询日志
     *
     * @param operatorName
     * @param returnValue
     * @param page
     * @param pageSize
     * @param operationTime
     * @return
     */
    @GetMapping("/getLogs")
    public Result getLogs(String operatorName,
                          String returnValue,
                          Integer page,
                          Integer pageSize,
                          @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate operationTime) {
        PageBean pageBean = logService.getLogPage(operatorName, returnValue, page, pageSize, operationTime);

        return Result.success(pageBean);
    }
}
